package visitor.pattern.simple.browser.test;

import lombok.extern.slf4j.Slf4j;
import visitor.pattern.simple.browser.internet.Bilibili;
import visitor.pattern.simple.browser.internet.Htmls;
import visitor.pattern.simple.browser.visitors.base.AbstractBaseVisitor;
import visitor.pattern.simple.browser.visitors.subscribe.AbstractSubscribeVisitor;

import java.util.Arrays;
import java.util.List;

/**
 * @Author: Coderlyz
 * @Date: 2023/4/3 21:05
 */
@Slf4j
public class VisitorImpl extends AbstractSubscribeVisitor {

    private MyVisitor myVisitor = new MyVisitor();


    @Override
    public List<Htmls.Types> getNodes() {
        return Arrays.asList(Htmls.Types.Baidu,Htmls.Types.Bilibili);
    }

    @Override
    public void visitNode(Htmls htmls) {
        htmls.show();
        htmls.accept(myVisitor);
    }

    private class MyVisitor extends AbstractBaseVisitor {

        @Override
        public void visitingBilibili(Bilibili bilibili) {
            bilibili.show();
        }
    }
}
